package com.pactera.config.security;

public enum AuthResultEnum {

	LOGIN_SUCCESS(0,"用户登录成功"),
	
    NEED_AUTHORITIES(201,"用户未登录"),
    LOGIN_FAILED(202,"用户账号或密码错误"),
    ACCESS_DEFINED(203,"用户无权访问"),
    
    LOGOUT_SUCCESS(204,"用户登出成功"),
    TOKEN_IS_BLACKLIST(205,"此token为黑名单"),
    LOGIN_IS_OVERDUE(206,"登录已失效"),
    ;
	
	private Integer code;

    private String message;
    
    public Integer getCode() {
		return code;
	}

	public String getMessage() {
		return message;
	}

    AuthResultEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 通过code返回枚举
    */
    public static AuthResultEnum parse(int code){
        AuthResultEnum[] values = values();
        for (AuthResultEnum value : values) {
            if(value.getCode() == code){
                return value;
            }
        }
        throw  new RuntimeException("Unknown code of ResultEnum");
    }
}
